package ch11.Concurrency;

/**
 * Created by 其 on 2016/4/9.
 */
import java.util.concurrent.BlockingQueue;

public class Consumer3 implements Runnable {
    private BlockingQueue<Integer> productQueue;

    public Consumer3(BlockingQueue<Integer> productQueue) {
        this.productQueue = productQueue;
    }

    public void run() {
        System.out.println("消费者开始消耗整数......");
        for(int i = 1; i <= 10; i++) {
            try {
                int product = productQueue.take();
                System.out.printf("消费者消费整数 (%d)%n", product);
            } catch (InterruptedException ex) {
                throw new RuntimeException(ex);
            }
        }
    }
}
